package com.boot.queue;

public class ArrayQueue {
    private int size;
    private int head;
    private int tail;
    private Integer[] data;
    public ArrayQueue(int size) {
        this.size =size;
        data = new Integer[size];
    }

    public void  add(Integer ele){
        if(isFull()){
            System.out.println("queue is full");
            return;
        }
        data[tail] = ele;
        
    }

    public int  get(){
        if(isEmpty()){
            System.out.println("queue  is empty");
            return -1;
        }
        return data[++tail];
    }

    public boolean isFull(){
        return head == size -1;
    }

    public boolean isEmpty(){
        return tail == head;
    }

    public static void main(String[] args) {
        ArrayQueue arrayQueue = new ArrayQueue(3);
        arrayQueue.add(10);
        arrayQueue.add(20);
        arrayQueue.add(30);
        arrayQueue.add(40);
        for (int i=0;i<4;i++){
            System.out.println(arrayQueue.get());
        }
    }
}
